package com.olympus.hermes.product.controller;

import com.olympus.hermes.common.support.PageRequest;
import com.olympus.hermes.product.bean.dto.brand.CreateBrandDTO;
import com.olympus.hermes.product.bean.dto.brand.OutputBrandDTO;
import com.olympus.hermes.product.service.BrandService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;


/**
 * @author Mickey
 * @since 2021/1/20
 */
@AllArgsConstructor
@RestController
@RequestMapping("/product/brand")
public class BrandController {

    private final BrandService brandService;

    @PostMapping("/create")
    public void create(@RequestBody @Valid CreateBrandDTO createBrand) {
        brandService.create(createBrand);
    }

    @GetMapping("/list")
    public Page<OutputBrandDTO> list(PageRequest pageRequest, Map<String, String> condition) {
        return brandService.listByCondition(pageRequest,condition);
    }

    @DeleteMapping("/delete")
    public void delete(@RequestParam("ids") List<Long> ids) {
        brandService.delete(ids);
    }
}
